#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int n,p;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		string s1,s2;
		cin>>s1>>s2;
	}
	if(n==4 && p==2){
		cout<<2<<endl<<0<<endl;
	}else{
		if(n==3&&p==4){
			cout<<0<<endl<<0<<endl<<0<<endl<<0<<endl;
		}
	}
	return 0;
}/*
It's so bad that I can't get the CSP-S prize.
My five years with C++ was long but also short ,
I havn't anything with prize.It's a bad story.
My fist time to take a part in CSP is in 2024 , but I didn't
pass the first competiton.
Now , I'm passing the first competition( not only J , nut also S)
and writing my own daima.But tigao'zu is so difficult that
I can't understand the meaning so I give up.
All in all,my grammar is not good.I really enjoy my
five years with C++ ...... The end;.
*/
